//+------------------------------------------------------------------+
//|                                                    handleapi.mqh |
//|                             Copyright 2000-2025, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#include <WinAPI/windef.h>

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
#import "kernel32.dll"
/// 关闭内核对象句柄
/// @param object 要关闭的对象句柄
/// @return 操作结果(成功为非零)
int CloseHandle(HANDLE object);

/// 复制对象句柄
/// @param source_process_handle 源进程句柄
/// @param source_handle 源对象句柄
/// @param target_process_handle 目标进程句柄
/// @param target_handle 返回复制的句柄
/// @param desired_access 期望的访问权限
/// @param inherit_handle 是否可继承
/// @param options 复制选项
/// @return 操作结果(成功为非零)
int DuplicateHandle(HANDLE source_process_handle, HANDLE source_handle, 
                    HANDLE target_process_handle, HANDLE &target_handle, 
                    uint desired_access, int inherit_handle, uint options);

/// 获取句柄信息
/// @param object 对象句柄
/// @param flags 返回的标志信息
/// @return 操作结果(成功为非零)
int GetHandleInformation(HANDLE object, uint& flags);

/// 设置句柄信息
/// @param object 对象句柄
/// @param mask 要设置的标志掩码
/// @param flags 要设置的标志值
/// @return 操作结果(成功为非零)
int SetHandleInformation(HANDLE object, uint mask, uint flags);
#import

#import "kernelbase.dll"
/// 比较两个对象句柄是否相同
/// @param first_object_handle 第一个对象句柄
/// @param second_object_handle 第二个对象句柄
/// @return 是否相同(1为相同)
int CompareObjectHandles(HANDLE first_object_handle, HANDLE second_object_handle); 
#import 
//+------------------------------------------------------------------+